package ch.bfh.parallaxis.activities;

import ch.bfh.parallaxis.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

public class TutorialActivity extends Activity {
	
	private ImageView tutorialOne;
	private ImageView tutorialTwo;
	private ImageView tutorialThree;
	private int screenCounter = 0;
	
	@Override
    public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
        
		final RelativeLayout mainView = new RelativeLayout(this);
        
        //tutorial 1
        tutorialOne = new ImageView(this);
        tutorialOne.setImageResource(R.drawable.tutorial_one);
        mainView.addView(tutorialOne); 
        
        LayoutParams paramsTutorialOne = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        tutorialOne.setLayoutParams(paramsTutorialOne);
        
        //tutorial 2
        tutorialTwo = new ImageView(this);
        tutorialTwo.setImageResource(R.drawable.tutorial_two);
        mainView.addView(tutorialTwo); 
        tutorialTwo.setVisibility(View.GONE);
        
        LayoutParams paramsTutorialTwo = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        tutorialTwo.setLayoutParams(paramsTutorialTwo);
        
        //tutorial 3
        tutorialThree = new ImageView(this);
        tutorialThree.setImageResource(R.drawable.tutorial_three);
        mainView.addView(tutorialThree);
        tutorialThree.setVisibility(View.GONE);
        
        LayoutParams paramsTutorialThree = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        tutorialThree.setLayoutParams(paramsTutorialThree);
        
        tutorialOne.setOnTouchListener(screenListener);
        tutorialTwo.setOnTouchListener(screenListener);
        tutorialThree.setOnTouchListener(screenListener);
        setContentView(mainView);
	}
	
	final OnTouchListener screenListener = new OnTouchListener() {
		@Override
		public boolean onTouch(View arg0, MotionEvent arg1) {
			screenCounter ++;
			
			if(screenCounter == 1){
				//slide 2
				tutorialOne.setVisibility(View.GONE);
				tutorialTwo.setVisibility(View.VISIBLE);
			}			
			else if(screenCounter == 2){
				//slide 3
				tutorialTwo.setVisibility(View.GONE);
				tutorialThree.setVisibility(View.VISIBLE);	  
				//screenCounter = 0;
	        }
			else if(screenCounter == 3){
				onPause();
				//Intent myIntent = new Intent(TutorialActivity.this, OptionActivity.class);
				//TutorialActivity.this.startActivity(myIntent);
			}
			
			return false;
		}
	};
	
	@Override
	public void onPause() {
		super.onPause();
		finish();
	}
	
}
